#! /bin/sh

log_dir=/var/log
proc_name="pcs-server.war"
log_name="/monitor.log"
pid=0

proc_val()                                            
{
	val=`echo -n "success" | gearman -h gearman.<%= @domain %> -t 1000 -f com.foxitcloud.scheduler.worker.EchoFunction`
}

proc_id() 
{
	pid=`ps -ef | grep $proc_name | grep -v grep | awk '{print $2}'`
}

proc_val
value=$val
if !( echo ${value} | grep -q success )
then 
	/sbin/service fxworker restart
	proc_id                             
	echo ${pid}, `date` >> $log_dir$log_name
fi

